<?php

namespace App\Models\Chat;

use App\Models\BaseModel;

/**
 * App\Models\Chat\SystemMessage
 *
 * @property int $id
 * @property string $user_id 用户ID
 * @property int $type 类型 系统信息0,好友申请1,进群申请2
 * @property string $target_id 目标ID  好友ID,群ID
 * @property string $message 内容
 * @property int $read 已读 ,默认未读
 * @property int $action 按钮状态 默认 可点击
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Chat\Group[] $group
 * @property-read int|null $group_count
 * @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
 * @property-read int|null $notifications_count
 * @method static \Illuminate\Database\Eloquent\Builder|SystemMessage newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|SystemMessage newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|SystemMessage query()
 * @method static \Illuminate\Database\Eloquent\Builder|SystemMessage whereAction($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SystemMessage whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SystemMessage whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SystemMessage whereMessage($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SystemMessage whereRead($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SystemMessage whereTargetId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SystemMessage whereType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SystemMessage whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SystemMessage whereUserId($value)
 * @mixin \Eloquent
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Member\Member[] $user
 * @property-read int|null $user_count
 */
class SystemMessage extends BaseModel
{

	protected $table ='chat_system_message';
	protected $primaryKey = 'id';
	public $timestamps = true;
	protected $fillable = [
		'user_id',
		'type',
		'target_id',
		'message',
		'read',
		'action',
	];
	// 寻找用户
	public function user ()
	{
		return $this->hasMany( 'App\Models\Member\Member','id','user_id');
	}
	//寻找群组
	public function group ()
	{
		return $this->hasMany('App\Models\Chat\Group','id','target_id');
	}
}
